class Vue {
    constructor(options) {
        //  初始化数据
        this.$options = options || {};
        this.$data = this.$options.data || {};
        const el = this.$options.el
        this.$el = typeof el === 'string' ? document.querySelector(el) : el;

        // 将data中的属性都挂在vue实例上
        this._proxyData(this.$data);

        new Observer(this.$data)

        new Compiler(this)
    }

    _proxyData(data) {
        Object.keys(data).forEach(key => {
            Object.defineProperty(this, key, {
                enumerable: true,
                configurable: true,
                get() {
                    return data[key]
                },
                set(newValue) {
                    if (newValue === data[key]) return;
                    data[key] = newValue;
                }
            })
        })
    }
}